package com.example.blogdemo.pojo.respond;

import com.example.blogdemo.enums.ResultEnumCode;
import com.sun.net.httpserver.Authenticator;
import lombok.Data;
import org.springframework.stereotype.Component;

@Data
public class Result {

    private ResultEnumCode code;
    private String errMsg;
    private Object data;

    public static Result success(Object data) {

        Result result = new Result();
        result.setCode(ResultEnumCode.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result fail(String message) {

        Result result = new Result();
        result.setCode(ResultEnumCode.FAIL);
        result.setErrMsg(message);
        return result;
    }

    public static Result fail(String message, Object data) {

        Result result = new Result();
        result.setCode(ResultEnumCode.FAIL);
        result.setErrMsg(message);
        result.setData(data);
        return result;
    }
}
